<template>
	<view>
		<view class="flex">
			<view class="flex-1 flex-y flex-x-y pr" @tap.stop="toPage('/pages/chat/group','',true)">
				<image src="../../static/fgx/f1.png" class="friend-other-image"></image>
				<view class="firend-other-text">群消息</view>
				<view class="hongdian" v-if="get_notes_group_num>0">
					{{get_num_text(get_notes_group_num)}}
				</view>
			</view>
			<view class="flex-1 flex-y flex-x-y pr" @tap.stop="toPage('/pages/chat/notice','',true)">
				<image src="../../static/fgx/f2.png" class="friend-other-image"></image>
				<view class="firend-other-text">系统通知</view>
				<view class="hongdian" v-if="show_notice_dot>0">
					{{get_num_text(show_notice_dot)}}
				</view>
			</view>
			<view class="flex-1 flex-y flex-x-y pr" @tap.stop="toPage('/pages/chat/search')">
				<image src="../../static/fgx/f3.png" class="friend-other-image"></image>
				<view class="firend-other-text">新朋友</view>
				<view class="hongdian" v-if="show_friend_new_dot>0">
					{{get_num_text(show_friend_new_dot)}}
				</view>
			</view>
		</view>
		<view style="display: none;">{{show_tabs2_dot}}</view>
	</view>
</template>

<script>
	export default {
		name: "friend-other",
		data() {
			return {
				list: [],

			};
		},
		watch: {
			chat_notes() {
				this.list = this.$store.state.chat_notes;
			},
		},
		computed: {
			show_notice_dot() {
				return this.$store.state.show_notice_dot;
			},
			show_friend_new_dot() {
				return this.$store.state.show_friend_new_dot;
			}, //显示是否有新的好友
			get_notes_group_num() {
				return this.list.filter(val => val.chatType == 'group').reduce((num, val) => num + Number(val.readNum), 0);
			},
			show_tabs2_dot() {

				if (this.get_notes_group_num > 0 || this.show_notice_dot > 0 | this.show_friend_new_dot > 0) {
					uni.showTabBarRedDot({
						index: 1,
					});
				} else {
					uni.hideTabBarRedDot({
						index: 1,
					});
				}
			},

		},
		created() {
			this.list = this.$store.state.chat_notes;
		},
		methods: {
			get_num_text(num) {
				if (num >= 100) {
					return '99+'
				}
				return num;
			},
		}
	}
</script>

<style lang="scss">
	.friend-other-image {
		width: 142rpx;
		height: 142rpx;
	}

	.firend-other-text {
		color: #333333;
		font-size: 30rpx;
		margin-top: -18rpx;
		font-weight: 600;
	}

	.hongdian {
		height: 30rpx;
		line-height: 30rpx;
		padding: 0 8rpx 0 10rpx;
		background-color: #FF4343;
		position: absolute;
		left: 60%;
		top: 0;

		border-radius: 15rpx;
		color: #FFFFFF;
		display: inline-block;
		min-width: 30rpx;
		font-size: 24rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>